<template>
	<view class="article" style="padding-bottom:260rpx">
		<!-- #ifdef MP-WEIXIN -->
		<view class="ad-banner-fixed bottom" v-show="api_host=='https://www.x-mii.com/app/index.php'">
			<ad unit-id="adunit-d0acacdb9aa0811d"></ad>
		</view>
		<!-- #endif -->
		<template v-if="article.out_link==''">
			<view class="title">{{article.title}}</view>
			<view class="author-time">
				<text class="author">作者：{{article.author}}</text>
				<text class="time">日期：{{article.public_time}}</text>
			</view>
			
			<view class="cover" v-if="article.image!=''">
				<image mode="widthFix" :src="article.image" ></image>
			</view>
			
			<view class="content">
				<u-parse :html="article.content" :selectable="true"></u-parse>
			</view>
			<view class="view-times">浏览量：{{article.viewtimes}}</view>
		</template>
		<template v-if="article.out_link!=''">
			<web-view :src="article.out_link"></web-view>
		</template>
		
	</view>
	

	
</template>

<script>
	var appInstance = getApp();
	export default {
		
		data() {
			return {
				api_host:appInstance.globalData.api_host,
				article_id:0,
				article:{
					
				}
			}
		},
		
		onLoad: function(options) {
		
			// this.shop_name = appInstance.globalData.shop_name;
			this.article_id = options.article_id;
			this.article_info();
			
		},
		
		onShareAppMessage: function (res) {
			// if (res.from === 'button') {
			//   // 来自页面内转发按钮
			//   console.log(res.target)
			// }
			return {
			  title: this.title,
			  path: '/sm_shop/pages/article/article?article_id='+this.article_id
			}
		},
		onShareTimeline:function(){
			return {
			  title: this.title,
			  path: 'sm_shop/pages/article/article?article_id='+this.article_id
			}
		},
		
		methods: {
			
			article_info:function(  ){
				
				
				var t = this;
				var url = '&r=article.single&id=' + this.article_id;
				
				appInstance.globalData.request(url, {m:'sm_shop_plugin_cms'}, 'GET', function(res) {
					t.article = res.data;
					t.article.out_link = t.article.out_link.replace(/^(\s+)|(\s+)$/g,'');
					console.log( t.article );
				});
				
			}
			
		}
	}
</script>

<style lang="less">
	@import './article.less';
</style>
